language: go

os:
  - linux
  - osx

go:
  - 1.8.3

env:
  global:
    - PROJ="github.com/elastic/gosigar"

sudo: false

before_install:
  # Put project into proper GOPATH location (important for forks).
  - mkdir -p $HOME/gopath/src/${PROJ}
  - rsync -az ${TRAVIS_BUILD_DIR}/ $HOME/gopath/src/${PROJ}/
  - export TRAVIS_BUILD_DIR=$HOME/gopath/src/${PROJ}
  - cd $HOME/gopath/src/${PROJ}

install:
  - go get -v -t -d ./...
  - go get github.com/elastic/beats/vendor/github.com/pierrre/gotestcover

script:
  - gofmt -l . | read && echo "Code differs from gofmt's style. Run 'gofmt -w .'" 1>&2 && exit 1 || true
  - go vet
  - go build
  - mkdir -p build/coverage
  - gotestcover -v -coverprofile=build/coverage/unit.cov github.com/elastic/gosigar/...
  - for i in $(ls examples); do go build -o examples/$i/$i ./examples/$i; ./examples/$i/$i; done

after_success:
  - bash <(curl -s https://codecov.io/bash) -f build/coverage/unit.cov
